﻿using System.ComponentModel.DataAnnotations;
using DataAccess;

namespace Business
{
    public abstract class BaseLogic
    {
        private IUnitOfWork _unitOfWork;

        protected IUnitOfWork UnitOfWork
        {
            get
            {
                return _unitOfWork ?? (_unitOfWork = new UnitOfWork());
            }
        }

        protected bool IsValid<TEntity>(TEntity entity)where TEntity:class
        {
            var vc = new ValidationContext(entity, null, null);
            return Validator.TryValidateObject(entity, vc, null, true);
        }
    }
}
